package qq.android.wan.test;

import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ListView;
import android.widget.PopupWindow;

import java.util.ArrayList;

public class MainActivity extends Activity implements View.OnClickListener{
    private Button btn;
private ListView listView;
    private ListViewAdapter adapter;
private ArrayList<String> datas;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       // this.btn = (Button) findViewById(R.id.btn);
      //  this.et = (EditText) findViewById(R.id.et);

        btn=(Button)findViewById(R.id.btn);
        btn.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {
        v.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.btn_rotate));
        PopupWindow popupWindow=new PopupWindow(this);
        View view=getLayoutInflater().inflate(R.layout.pop,null);
        listView=(ListView)view.findViewById(R.id.listView);
        datas=new ArrayList<String>();
        for(int i=0;i<10;i++){
            datas.add(i+"");
        }
        adapter=new ListViewAdapter(datas,this);
        listView.setAdapter(adapter);
        popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        popupWindow.setFocusable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setContentView(view);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.setAnimationStyle(R.style.popwin_anim_style);
       popupWindow.showAtLocation(findViewById(R.id.main), Gravity.BOTTOM, 0, 0);
        WindowManager.LayoutParams lp=getWindow().getAttributes();
        lp.alpha=0.1f;
        getWindow().setAttributes(lp);
    }
}
